package com.xy.utils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @BelongsPackage: com.xy.utils
 * @Author: WK
 * @CreateTime: 2023-07-26
 * @Description:
 * @Version: 1.0
 */
public class StrUtil implements Serializable {
	public static String trim(String str) {
		return str.replace(" ", "");
	}
	/**
	 * 生成设备编号
	 * @return
	 */
	public static String deviceNo(){
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmssSSS");
		String  formDate =sdf.format(date);
		String no = formDate.substring(14);
		int[] array ={0,1,2,3,4,5,6,7,8,9};
		Random rand = new Random();
		for (int i = 10; i > 1; i--) {
			int index =rand.nextInt(i);
			int tmp =array[index];
			array[index] = array[i - 1];
			array[i - 1] = tmp;
		}
		int result = 0;
		for(int i = 0; i < 6; i++){
			result = result * 10 + array[i];
		}
		return Integer.toString(result).concat(no);
	}
}
